package com.learn.training.multithread.chapter8.demo2;

import java.util.concurrent.*;

public class Demo {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ExecutorService es = Executors.newFixedThreadPool(4);

        // 定义一个Callable任务
        Callable<String> task = new Task();

        // 提交任务并获取Future对象
        Future<String> future = es.submit(task);

        // 从Future对象中获取异步执行结果
        String result = future.get();
        System.out.println("Result: " + result);

        es.shutdown();
    }
}
